import networkx as nx
import matplotlib.pyplot as plt
import random

# 创建一个空图
G = nx.Graph()

# 添加200个节点
G.add_nodes_from(range(3885))

# 随机生成5000条边，允许重复添加会自动忽略
while G.number_of_edges() < 7260:
    # 在节点间随机选择两个节点，创建一条边
    u = random.randint(0, 3885)
    v = random.randint(0, 3885)
    if u != v:  # 确保没有自环
        G.add_edge(u, v)

# 绘制网络图
plt.figure(figsize=(200, 120))  # 设置图的大小
nx.draw(G, node_size=100, edge_color="grey", node_color="red") # 绘制图
plt.title("Network Topology with 200 Nodes and 5000 Edges")
# plt.show()
plt.savefig('topo.svg', format="svg")
